<?php

/**
 * Created by JetBrains PhpStorm.
 * User: GMC02
 * Date: 9/25/13
 * Time: 4:46 PM
 * To change this template use File | Settings | File Templates.
 */
class TreTodayUrl {

    // region Common

    public static function home() {
        return Yii::app()->getBaseUrl(true);
    }


    // endregion

    // region User
    public static function login() {
        return CHtml::normalizeUrl(array('user/login'));
    }

    public static function loginOpenID($provider = 'facebook') {
        return CHtml::normalizeUrl(array('user/openid', 'provider' => $provider));
    }

    public static function logout() {
        return CHtml::normalizeUrl(array('user/logout'));
    }

    // endregion

    //region BACK-END

    public static function backendUrl() {
        return Yii::app()->BaseUrl . '/backend.php';
    }

    public static function backendDefaultUrl() {
        return TreTodayUrl::backendUrl() . '/site/index';
    }

    public static function backendLoginUrl() {
        return TreTodayUrl::backendUrl() . '/userBack/login';
    }

    public static function backendLogoutUrl() {
        return TreTodayUrl::backendUrl() . '/userBack/logout';
    }

    public static function backendAdsUrl() {
        return TreTodayUrl::backendUrl() . '/ads/index';
    }

    public static function backendAdsCreateUrl() {
        return TreTodayUrl::backendUrl() . '/ads/create';
    }

    public static function backendBuyMethodUrl() {
        return TreTodayUrl::backendUrl() . '/buyMethod/index';
    }

    public static function backendBuyMethodCreateUrl() {
        return TreTodayUrl::backendUrl() . '/buyMethod/create';
    }

    public static function backendBuyWayUrl() {
        return TreTodayUrl::backendUrl() . '/buyWay/index';
    }

    public static function backendBuyWayCreateUrl() {
        return TreTodayUrl::backendUrl() . '/buyWay/create';
    }

    public static function backendCategoryUrl() {
        return TreTodayUrl::backendUrl() . '/category/index';
    }

    public static function backendCategoryCreateUrl() {
        return TreTodayUrl::backendUrl() . '/category/create';
    }

    public static function backendCategoryPositionUrl() {
        return TreTodayUrl::backendUrl() . '/categoryPosition/index';
    }

    public static function backendCategoryPositionCreateUrl() {
        return TreTodayUrl::backendUrl() . '/categoryPosition/create';
    }

    public static function backendGuestBookUrl() {
        return TreTodayUrl::backendUrl() . '/guestBook/index';
    }

    public static function backendGuestBookCreateUrl() {
        return TreTodayUrl::backendUrl() . '/guestBook/create';
    }

    public static function backendProductUrl($published) {
        return TreTodayUrl::backendUrl() . '/product/index?published=' . $published;
    }

    public static function backendProductCreateUrl() {
        return TreTodayUrl::backendUrl() . '/product/create';
    }

    public static function backendUserBackUrl() {
        return TreTodayUrl::backendUrl() . '/userBack/index';
    }

    public static function backendUserBackCreateUrl() {
        return TreTodayUrl::backendUrl() . '/userBack/create';
    }

    public static function backendUserRaoVatUrl() {
        return TreTodayUrl::backendUrl() . '/userRaoVatInfo/index';
    }

    public static function backendUserRaoVatCreateUrl() {
        return TreTodayUrl::backendUrl() . '/userRaoVatInfo/create';
    }

    public static function backendUserBackLog() {
        return TreTodayUrl::backendUrl() . '/userBack/log';
    }

    //region User
    public static function backendUserUrl() {
        return TreTodayUrl::backendUrl() . '/user/index';
    }

    public static function backendUserCreateUrl() {
        return TreTodayUrl::backendUrl() . '/user/create';
    }

    public static function getPictureUrl($url) {
        return TreTodayUrl::home() . "/$url";
    }

    public static function getSmallAvatarUrl($url) {
        if (trim($url) == '') return '';
        $url = explode('.', $url);

        $pic = $url[0] . '_thumb_48x48.' . $url[1];
        return TreTodayUrl::home() . "/$pic";
    }

    //endregion

    //endregion

    public static function getChangeThemeUrl($name) {
        return TreTodayUrl::home() . '/change/' . $name;
    }

    public static function getCategoryUrl($id, $name, $location = 0, $location_name = '') {
        if ($location > 0 && $location_name != '') {
            return TreTodayUrl::home() . '/category/' . $id . '/' . TreTodayCommon::getSEO($name) . "/$location/" . TreTodayCommon::getSEO($location_name);
        }
        return TreTodayUrl::home() . '/category/' . $id . '/' . TreTodayCommon::getSEO($name);
    }

    public static function getAppUrl($str) {
        return TreTodayUrl::home() . "/app/$str";
    }

    public static function  getProductUrl($id, $name) {
        return TreTodayUrl::home() . "/product/$id/" . TreTodayCommon::getSEO($name) . '.html';
    }

    public static function getBlankImage() {
        return TreTodayUrl::home() . '/images/graphics/blank.gif';
    }

    public static function getUserUrl($id, $name) {
        return TreTodayUrl::home() . "/user/$id/" . TreTodayCommon::getSEO($name);
    }

    public static function getLoginUrl() {
        return TreTodayUrl::home() . '/user/login';
    }

    public static function getLogoutUrl() {
        return TreTodayUrl::home() . '/user/logout';
    }

    public static function getRegisterUrl() {
        return TreTodayUrl::home() . '/user/register';
    }

    public static function getUpProductUrl() {
        return TreTodayUrl::home() . '/product/up';
    }

    public static function getUpdateProductUrl($id, $name) {
        return TreTodayUrl::home() . '/product/update/' . $id . '/' . TreTodayCommon::getSEO($name);
    }

    public static function backendMenuItemUrl() {
        return TreTodayUrl::backendUrl() . '/menuItem/index';
    }

    public static function backendMenuItemCreateUrl() {
        return TreTodayUrl::backendUrl() . '/menuItem/create';
    }

    public static function backendBannerUrl() {
        return TreTodayUrl::backendUrl() . '/banner/index';
    }

    public static function backendCreateBannerUrl() {
        return TreTodayUrl::backendUrl() . '/banner/create';
    }

    public static function editBuyWayUrl($user_id) {
        return TreTodayUrl::home() . '/user/' . $user_id . '/thong-tin-thanh-toan';
    }

    public static function getActiveAccount($code) {
        return TreTodayUrl::home() . '/user/active/' . $code;
    }

    public static function getActiveProduct($code) {
        return TreTodayUrl::home() . '/product/active/' . $code;
    }

    public static function  getLatestProductsUrl($location = 0, $name = '') {
        if ($location == 0)
            return TreTodayUrl::home() . '/product/moi-nhat/';
        else
            return TreTodayUrl::home() . '/product/moi-nhat/' . $location . '/' . TreTodayCommon::getSEO($name);
    }

    public static function getInterestedUrl() {
        return TreTodayUrl::home() . "/co-the-ban-quan-tam";
    }

    public static function getInterestedUrlByCategory($id, $name, $location = '', $location_name = '') {
        if ($location > 0 && $location_name != '') {
            return TreTodayUrl::home() . "/co-the-ban-quan-tam/$id/" . TreTodayCommon::getSEO($name) . "/$location/" . TreTodayCommon::getSEO($location_name);
        } else
            return TreTodayUrl::home() . "/co-the-ban-quan-tam/$id/" . TreTodayCommon::getSEO($name);
    }
}
